import request from '@/utils/request'
import type { VacationRule, CommonResponse, ListResponse, VacationBalanceResponse, UpdateBalanceParams, UpdateBalanceResponse } from './types/vacation'

// 获取假期规则列表
export function getVacationRules() {
  return request.get<ListResponse>('/kaoqin/holiday')
}

// 添加假期规则
export function addVacationRule(data: Omit<VacationRule, 'id'>) {
  return request.post<CommonResponse>('/kaoqin/holiday', data)
}

// 更新假期规则
export function updateVacationRule(data: any) {
  return request.put('/kaoqin/holiday', data)
}

// 删除假期规则
export function deleteVacationRule(id: number) {
  return request.delete<CommonResponse>('/kaoqin/holiday', {
    data: { id }
  })
}

// 获取假期余额列表
export function getVacationBalance(data:any) {
  return request({
    url:'/kaoqin/balance',
    method:'get',
    params:data
  })
}

// 更新假期余额
export function updateVacationBalance(data: UpdateBalanceParams) {
  return request.put<UpdateBalanceResponse>('/kaoqin/balance', data)
} 


// 假期规则初始化
export function Vacationbone() {
  return request.put('/init/holiday')
} 




// 年假余额初始化
export function yearVacationbone() {
  return request.post('/init/holiday')
} 

// 获取假期日志
export function getVacationlog(datass:any) {
  return request({
    url:'/balance/log',
    method:'get',
    params:datass
  })
}

